﻿

using COVID_19_LiquidFillUI.Models;
using Microsoft.EntityFrameworkCore;

namespace COVID_19_LiquidFillUI
{
    public class MDbContext : DbContext
    {
        private string DbPath;
        public DbSet<MVisionPoint1> MVisionPoint1s { get; set; }
        public DbSet<MVisionPoint2> MVisionPoint2s { get; set; }
        public DbSet<MDrawCircle> MDrawCircles { get; set; }
        public DbSet<MJudge> MJudges { get; set; }
        protected override void OnConfiguring(DbContextOptionsBuilder options)
        {
            options.UseSqlite($"Data Source={DbPath};Pooling=False");
        }
        public MDbContext()
        {
            var path = System.AppDomain.CurrentDomain.BaseDirectory;
            DbPath = System.IO.Path.Join(path, "point.db");
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<MVisionPoint1>(entity =>
            {
                entity.HasKey(e => e.Id);
            });
            modelBuilder.Entity<MVisionPoint2>(entity =>
            {
                entity.HasKey(e => e.Id);
            });
            modelBuilder.Entity<MDrawCircle>(entity =>
            {
                entity.HasKey(e => e.Id);
            });
            modelBuilder.Entity<MJudge>(entity =>
            {
                entity.HasKey(e => e.Id);
            });
        }
    }
}
